package com.search.app.Controller;

import com.search.app.Service.CommoditySearchService;
import com.search.app.VO.Product;
import com.search.app.VO.Productimage;
import com.search.app.VO.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SearchController {

    @Autowired
    CommoditySearchService commoditySearchService;


    /**
     * 根据关键词查询 返回查询结果
     * @param keyWord 关键词
     * @return 返回查询结果
     */
    @GetMapping("Search")
    public SearchResult SearchResult(@RequestParam(defaultValue = "") String keyWord){
        List<Product> list =(List<Product>) commoditySearchService.keyWordSearch(keyWord);
        SearchResult searchResult=new SearchResult();
        searchResult.setData(list);
        return searchResult;
    }


}
